<script lang="ts" setup>
import { type AlbumVO } from '@/request/api/album'
import { RouteNameEnum } from '@/enum'

const router = useRouter()

const { data } = defineProps({
  data: {
    type: Array<AlbumVO>,
    required: true
  }
})
</script>

<template>
  <el-container class="auto-column p-5">
    <el-container
      v-for="p in data"
      :key="p.id"
      v-slide-in
      class="img-box cursor-pointer relative aspect-[3/4] use-radius-sm use-shadow use-transitions-shadow-short"
      @click="
        router.push({
          name: RouteNameEnum.ALBUM_DETAIL,
          params: {
            id: p.id
          }
        })
      "
    >
      <el-main class="absolute duration-200 z-10 size-full bg-gray-600/30" />

      <ImageBox :url="p.paths[0]" class="absolute" />
      <span
        class="flex items-center justify-center size-8 use-radius-xs bg-gray-900/50 absolute z-20 right-5 top-5"
      >
        {{ p.paths.length }}
      </span>
      <el-container
        class="absolute text-white z-20 duration-300 bottom-0 p-5 gap-1"
        direction="vertical"
      >
        <span class="text-2xl ellipsis-1">{{ p.title }}</span>
        <SvgIcon :message="p.createTime.toString()" name="edit" />
      </el-container>
    </el-container>
  </el-container>
</template>

<style lang="scss" scoped>
.img-box {
  &:hover {
    & .el-main {
      background-color: transparent;
    }
  }
}
</style>
